package com.atguigu.gmall.seckill.rest;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.common.result.ResultCodeEnum;
import com.atguigu.gmall.seckill.biz.SeckillBizService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/activity/seckill")
public class SeckillRestController {

    @Autowired
    SeckillBizService seckillBizService;

    //    /auth/getSeckillSkuIdStr/51
    @GetMapping("/auth/getSeckillSkuIdStr/{skuId}")
    public Result getSeckillSkuIdStr(@PathVariable Long skuId) {
        String SeckillCode = seckillBizService.getSeckillSkuIdStr(skuId);
        return Result.ok(SeckillCode);
    }


    @PostMapping("/auth/seckillOrder/{skuId}")
    public Result seckillOrder(@PathVariable Long skuId, String skuIdStr) {
        ResultCodeEnum res = seckillBizService.seckillOrder(skuId, skuIdStr);
        return Result.build(null, res);
    }

    @GetMapping("/auth/checkOrder/{skuId}")
    public Result checkOrder(@PathVariable Long skuId) {
        ResultCodeEnum res = seckillBizService.checkOrder(skuId);
        return Result.build(null, res);
    }
}
